home *** CD-ROM | disk | FTP | other *** search
- /**
- * This is an example of a program which uses the shade interactor. The
- * point of the shade interactor is to show you how you can design and
- * build new interactors for new interactions.
- * @author Ian Smith
- */
- package sub_arctic.test;
-
- import sub_arctic.lib.*;
- import sub_arctic.input.*;
- import sub_arctic.anim.*;
- import sub_arctic.output.*;
- import sub_arctic.constraints.std_function;
-
- import java.awt.Font;
-
- public class shade_test extends debug_interactor_applet implements callback_object {
- /**
- * Initial font size
- */
- int font_size=12;
- /**
- * Labels on the toggles
- */
- String sizes[] = { "Eight Point", "Ten Point", "Twelve Point",
- "Fourteen Point"};
- /**
- * The maping to actual sizes
- */
- int point_sizes[] = {8, 10, 12, 14};
- /**
- * The collection of toggles
- */
- text_toggle_collection ttc;
- /**
- * The HTML text flow
- */
- text_flow flow;
- /**
- * Build the UI
- */
- public void build_ui(base_parent_interactor top) {
- base_parent_interactor bpi;
- button tmp;
- label tlab;
- /* build the shade */
- shade s=new shade();
- top.add_child(s);
- /* shade will fill the whole applet */
- s.set_x(0);
- s.set_y(0);
- s.set_w_constraint(std_function.offset(PARENT.X2(), 0));
- s.set_h_constraint(std_function.offset(PARENT.Y2(), 0));
- /* lets build a little UI to put in the shade */
- /* we override this with constraints */
- bpi=new base_parent_interactor(0,0,370,300);
- bpi.set_w_constraint(std_function.offset(PARENT.W(), 0));
- bpi.set_h_constraint(std_function.offset(PARENT.H(), -40));
- /* put a text flow in it */
- flow=new text_flow(getParameter("TEXT"),350,300);
- flow.set_w_constraint(std_function.offset(PARENT.W(), -20));
- flow.set_h_constraint(std_function.offset(PARENT.H(), -35));
- flow.set_x(10);
- flow.set_y(15);
- bpi.add_child(flow);
- /* put some buttons below it */
- tmp=new button("Back",null);
- bpi.add_child(tmp);
- tmp.set_x_constraint(std_function.eq(PREV_SIBLING.X()));
- tmp.set_y_constraint(std_function.far_edge_just(PARENT.H(), 5));
-
- tmp=new button("Foward",null);
- bpi.add_child(tmp);
- tmp.set_x_constraint(std_function.offset(PREV_SIBLING.X2(), 5));
- tmp.set_y_constraint(std_function.far_edge_just(PARENT.H(), 5));
-
- tmp=new button("Home",null);
- bpi.add_child(tmp);
- tmp.set_x_constraint(std_function.offset(PREV_SIBLING.X2(), 15));
- tmp.set_y_constraint(std_function.far_edge_just(PARENT.H(), 5));
- /* make this parent a child of the shade */
- s.set_child(0,bpi);
- /*
- * Ok, now get ready for the second child of the shade (on
- * top of the shade)
- */
- bpi=new base_parent_interactor(0,0,100,200); // overriden width
- bpi.set_w_constraint(std_function.offset(PARENT.W(),0));
- /* put in a label */
- tlab = new label("Reformat text as:", new Font("Helvetica",Font.BOLD,14));
- tlab.set_x_constraint(std_function.centered(PARENT.W(), 0));
- tlab.set_y_constraint(std_function.offset(PARENT.Y(), 50));
- bpi.add_child(tlab);
- /* make a set of toggles for the shade */
- ttc=new text_toggle_collection(sizes,true,-1,this);
- ttc.set_x_constraint(std_function.centered(PARENT.W(), 0));
- ttc.set_y_constraint(std_function.offset(PREV_SIBLING.Y2(), 5));
- /* put the toggles in place */
- bpi.add_child(ttc);
- /* we are initially at 12 point */
- ttc.nth_toggle(2).set_cur_state(1);
- /* make this bpi be the child of the shade in slot 1 */
- s.set_child(1,bpi);
- }
- /**
- * Handle a callback from the radio buttons.
- */
- public void callback(interactor from_obj,event evt, int callback_num,
- Object callback_info) {
-
- Integer i=(Integer)callback_info;
- int index=ttc.find_child(from_obj);
- /* is it already that size? */
- if (point_sizes[index]==font_size) return;
- /* it isn't the same size ... do it */
- font_size=point_sizes[index];
- /* set the size */
- flow.set_font_size(font_size);
- /* force a relayout */
- flow.set_text(flow.text());
- }
- }
-
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-